package com.example.smokealarm.repository;

import com.example.smokealarm.model.LoginAccount;
import com.example.smokealarm.model.RpiData;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.List;


@Repository
public interface RpiDataRepository extends JpaRepository<RpiData, Long>
{

    @Query("SELECT d FROM RpiData d WHERE d.time >= :timeAgo ORDER BY d.time ASC")
    List<RpiData> findRecentData(LocalDateTime timeAgo);

    @Query("SELECT d FROM RpiData d WHERE d.time >= :timeAgo ORDER BY d.time ASC")
    List<RpiData> findSmokeData(LocalDateTime timeAgo);
}
